package Engine;

import View.Novo;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.MaskFormatter;

public class Ajuste extends JFrame {
    
    public void jTextFieldAlwayUpperCase(final JTextField jt) {
        jt.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                jTextFieldtoUpper(jt);
            }
        });
    }
    
    public void jTextAreaAlwayUpperCase(final JTextArea jta) {
        jta.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                jTextAreatoUpper(jta);
            }
        });
    }
  
    public void jTextFieldtoUpper(JTextField jt) {
        String s = jt.getText().toUpperCase();
        jt.setText(s);
    }
    
    public void jTextAreatoUpper(JTextArea jta) {
        String s = jta.getText().toUpperCase();
        jta.setText(s);
    }
    
    public void telefoneFormatt(){
        try {
            MaskFormatter telefone = new MaskFormatter("(##) ####-####");
            Novo.telefone.setFormatterFactory(new DefaultFormatterFactory(telefone));
        } catch (ParseException ex) {
            Logger.getLogger(Ajuste.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    
}
